<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>dexterind-temp-test1.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="preprocessor">#pragma config(Sensor, S1,     DTMP,                sensorAnalogInactive)</span>
<span class="preprocessor"></span><span class="comment">//*!!Code automatically generated by &#39;ROBOTC&#39; configuration wizard               !!*//</span>
<span class="comment"></span>
<span class="comment">/**</span>
<span class="comment"> * dexterind-temp.h provides an API for the Dexter Industries Temperature Probe.  This program</span>
<span class="comment"> * demonstrates how to use that API.</span>
<span class="comment"> *</span>
<span class="comment"> * Changelog:</span>
<span class="comment"> * - 0.1: Initial release</span>
<span class="comment"> *</span>
<span class="comment"> * Credits:</span>
<span class="comment"> * - Big thanks to Dexter Industries for providing me with the hardware necessary to write and test this.</span>
<span class="comment"> *</span>
<span class="comment"> * License: You may use this code as you wish, provided you give credit where it&#39;s due.</span>
<span class="comment"> *</span>
<span class="comment"> * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. </span>
<span class="comment"></span>
<span class="comment"> * Xander Soldaat (xander_at_botbench.com)</span>
<span class="comment"> * 13 June 2010</span>
<span class="comment"> * version 0.1</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &quot;<a class="code" href="dexterind-temp_8h.html" title="ROBOTC DI Temp Probe Driver.">drivers/dexterind-temp.h</a>&quot;</span>

task main() {
  <span class="keywordtype">float</span> temp;
  byte state = 0;

  nxtDisplayTextLine(0, <span class="stringliteral">&quot;Dexter Industries&quot;</span>);
  nxtDisplayCenteredBigTextLine(1, <span class="stringliteral">&quot;T Probe&quot;</span>);
  nxtDisplayCenteredTextLine(3, <span class="stringliteral">&quot;Test 1&quot;</span>);
  nxtDisplayCenteredTextLine(5, <span class="stringliteral">&quot;Connect sensor&quot;</span>);
  nxtDisplayCenteredTextLine(6, <span class="stringliteral">&quot;to S1&quot;</span>);
  wait1Msec(2000);
  eraseDisplay();

  nxtDisplayTextLine(0, <span class="stringliteral">&quot;Dexter Industries&quot;</span>);
  nxtDisplayCenteredTextLine(7, <span class="stringliteral">&quot;&lt; switch scale &gt;&quot;</span>);
  <span class="comment">//loop to read temp</span>
  <span class="keywordflow">while</span> (<span class="keyword">true</span>) {
    <span class="keywordflow">switch</span>(nNxtButtonPressed) {
      <span class="comment">// If the right button is pressed, cycle through the scales</span>
      <span class="keywordflow">case</span> kRightButton:
        <span class="keywordflow">if</span> (++state &gt; 2)
          state = 0;
        <span class="keywordflow">while</span> (nNxtButtonPressed != kNoButton) EndTimeSlice();
        <span class="keywordflow">break</span>;

        <span class="comment">// If the left button is pressed, cycle through the scales in reverse</span>
      <span class="keywordflow">case</span> kLeftButton:
        <span class="keywordflow">if</span> (--state &lt; 0)
          state = 2;
        <span class="comment">// debounce the button</span>
        <span class="keywordflow">while</span> (nNxtButtonPressed != kNoButton) EndTimeSlice();
        <span class="keywordflow">break</span>;
    }


    nxtDisplayCenteredBigTextLine(1, <span class="stringliteral">&quot;Temp:&quot;</span>);
    <span class="keywordflow">switch</span>(state) {
      <span class="comment">// if state: 0, display temp in degrees celcius</span>
      <span class="keywordflow">case</span> 0: <a name="a0"></a><a class="code" href="group__d_temp.html#gae52ceafabf7ecf68ebf15f160c7a9ad3">DTMPreadTemp</a>(DTMP, temp);
              nxtDisplayCenteredBigTextLine(3, <span class="stringliteral">&quot;%4.2f&quot;</span>, temp);
              nxtDisplayCenteredBigTextLine(5, <span class="stringliteral">&quot;Celcius&quot;</span>);
              <span class="keywordflow">break</span>;

      <span class="comment">// if state: 1, display temp in Fahrenheit</span>
      <span class="keywordflow">case</span> 1: <a name="a1"></a><a class="code" href="group__d_temp.html#gafc74d84da9d53049bab3ccb37fb3bdbd">DTMPreadTempF</a>(DTMP, temp);
              nxtDisplayCenteredBigTextLine(3, <span class="stringliteral">&quot;%4.2f&quot;</span>, temp);
              nxtDisplayCenteredBigTextLine(5, <span class="stringliteral">&quot;Fahrenh.&quot;</span>);
              <span class="keywordflow">break</span>;

      <span class="comment">// if state: 2, display temp in Kelvin</span>
      <span class="keywordflow">case</span> 2: <a name="a2"></a><a class="code" href="group__d_temp.html#gadf43277ed36d9e3141f84faa6e2d68dc">DTMPreadTempK</a>(DTMP, temp);
              nxtDisplayCenteredBigTextLine(3, <span class="stringliteral">&quot;%4.2f&quot;</span>, temp);
              nxtDisplayCenteredBigTextLine(5, <span class="stringliteral">&quot;Kelvin&quot;</span>);
              <span class="keywordflow">break</span>;
    }
    wait1Msec(10);
  }
}
</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:41 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
